package com.poisonh.unifiedauth.utils;

import android.os.CountDownTimer;
import android.widget.Button;

import com.poisonh.unifiedauth.R;

/**
 * 一些公共的工具类
 * Created by PoisonH on 2016/7/18.
 */
public class CommonUtils
{
    /**
     * 倒计时
     */
    public static void CountdownTime(final Button btn)
    {
        new CountDownTimer(60000, 1000)
        {

            public void onTick(long millisUntilFinished)
            {
                btn.setText("剩余" + millisUntilFinished / 1000 + "s");
            }

            public void onFinish()
            {
                btn.setText(R.string.login_tips_btn_phonecode);
                btn.setEnabled(true);
            }
        }.start();
    }

    /**
     * 校验手机号
     *
     * @return
     */
    public static boolean checkPhone(String mStrPhone)
    {
        return !mStrPhone.isEmpty() && RegexUtils.isMobilePhoneNumber(mStrPhone);
    }
}
